﻿Imports System.Data.OleDb

Public Class Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
    End Sub


    Protected Sub LoginUser_LoggedIn1(sender As Object, e As EventArgs) Handles LoginUser.LoggedIn
        Dim username As String = LoginUser.UserName
        Dim userId As Int32 = New aspnet_UsersManagement().SelectUserIDByUsername(username)

        Dim getProfile As ProfilesManagement = New ProfilesManagement()
        Dim dr As OleDbDataReader = getProfile.SelectProfileByUserID(userId)

        Dim blocked As Boolean = False

        If dr.HasRows Then
            dr.Read()
            If Not IsDBNull(dr("ProfileBlocked")) Then blocked = dr("ProfileBlocked")
        End If

        If (blocked = False) Then


            Dim myIdCookie As HttpCookie = New HttpCookie("userIdCookie", userId)
            myIdCookie.Expires = DateTime.Now.AddDays(9)
            Response.Cookies.Add(myIdCookie)

        Else
            FormsAuthentication.SignOut()
        End If


    End Sub
End Class